package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//攻略分类
@Setter@Getter
@JsonIgnoreProperties("handler")
public class StrategyCatalog extends BaseDomain {
    private String name; //攻略名称

    private Integer sequence; //序号

    private boolean state; //状态 启用true,禁用false

    /*这个样传统设计是没有问题的,但是在某个需求上封装比价麻烦
    可以适当使用冗余数据
    private Strategy strategy; //所属大攻略*/
    private Long strategyId;
    private String strategyTitle;

    private List<StrategyDetail> details = new ArrayList<>(); //攻略文章

    public String getStateName() {
        String msg = "禁用";
        if (state) {
            msg = "启用";
        }
        return msg;
    }

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("sequence", sequence);
        map.put("state", state);
        map.put("strategyId", strategyId);
        return JSONUtil.toJSONString(map);
    }
}